from selenium.webdriver.common.by import By

from weixin_po.commom.BasePage import BasePage
from weixin_po.page_object.personnel_list import personnellist
from weixin_po.utils.log_util import logger


class editpage(BasePage):
    _input_username = (By.ID, "username")
    _input_accid = (By.CSS_SELECTOR, "#memberAdd_acctid")
    _input_phone = (By.CSS_SELECTOR, "#memberAdd_phone")
    _save_button = (By.CSS_SELECTOR, ".qui_btn.ww_btn.js_btn_save")
    _phone_list = (By.XPATH, "//tr//td[5]")

    def edit_contact(self, username, accid, mobile):
        logger.info("填写成员信息")
        self.find_send_keys(username, self._input_username)
        self.find_send_keys(accid, self._input_accid)
        self.find_send_keys(mobile, self._input_phone)
        self.finds(self._save_button)[0].click()

        return personnellist(self.driver)
